/**
  ******************************************************************************
  * @file    TIM/TIM_TimeBase/main.c 
  * @author  MCD Application Team
  * @version V1.3.0
  * @date    13-November-2013
  * @brief   Main Interrupt Service Routines.
  *          This file provides template for all exceptions handler and peripherals
  *          interrupt service routine.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"
#include "main.h"

/** @addtogroup STM32F4xx_StdPeriph_Examples
  * @{
  */

/** @addtogroup TIM_TimeBase
  * @{
  */ 

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
uint16_t capture = 0;
extern __IO uint16_t CCR1_Val;
extern __IO uint16_t CCR2_Val;
extern __IO uint16_t CCR3_Val;
extern __IO uint16_t CCR4_Val;

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/******************************************************************************/
/*            Cortex-M4 Processor Exceptions Handlers                         */
/******************************************************************************/

/**
  * @brief  This function handles NMI exception.
  * @param  None
  * @retval None
  */
void NMI_Handler(void)
{
}

/**
  * @brief  This function handles Hard Fault exception.
  * @param  None
  * @retval None
  */
void HardFault_Handler(void)
{
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)
  {}
}

/**
  * @brief  This function handles Memory Manage exception.
  * @param  None
  * @retval None
  */
void MemManage_Handler(void)
{
  /* Go to infinite loop when Memory Manage exception occurs */
  while (1)
  {}
}

/**
  * @brief  This function handles Bus Fault exception.
  * @param  None
  * @retval None
  */
void BusFault_Handler(void)
{
  /* Go to infinite loop when Bus Fault exception occurs */
  while (1)
  {}
}

/**
  * @brief  This function handles Usage Fault exception.
  * @param  None
  * @retval None
  */
void UsageFault_Handler(void)
{
  /* Go to infinite loop when Usage Fault exception occurs */
  while (1)
  {}
}

/**
  * @brief  This function handles Debug Monitor exception.
  * @param  None
  * @retval None
  */
void DebugMon_Handler(void)
{}

/**
  * @brief  This function handles SVCall exception.
  * @param  None
  * @retval None
  */
void SVC_Handler(void)
{}

/**
  * @brief  This function handles PendSV_Handler exception.
  * @param  None
  * @retval None
  */
void PendSV_Handler(void)
{}

/**
  * @brief  This function handles SysTick Handler.
  * @param  None
  * @retval None
  */
__attribute__((weak)) void SysTick_Handler(void)
{}

/******************************************************************************/
/*            STM32F4xx Peripherals Interrupt Handlers                        */
/******************************************************************************/

extern TIM_HandleTypeDef    TimHandle;

/**
  * @brief  This function handles TIM3 global interrupt request.
  * @param  None
  * @retval None
  */
void TIM3_IRQHandler(void)
{
  HAL_TIM_IRQHandler(&TimHandle);
}

/**
  * @brief  This function handles TIM4 global interrupt request.
  * @param  None
  * @retval None
  */
void TIM4_IRQHandler(void)
{
  //HAL_TIM_IRQHandler(&TimHandle);
//	  HAL_TIM_IRQHandler(&TimHandle);
processStream();
 //clearTimUpdateFlag(&TimHandle);
 //__HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
}

void SPIx_DMA_TX_IRQHandler(void)
{
  HAL_DMA_IRQHandler(SpiHandle.hdmatx);
}

void SPIx_DMA_RX_IRQHandler(void)
{
  HAL_DMA_IRQHandler(SpiHandle.hdmarx);
}

/**
  * @brief  This function handles UART interrupt request.
  * @param  None
  * @retval None
  * @Note   This function is redefined in "main.h" and related to DMA stream
  *         used for USART data transmission
  */
void USARTx_IRQHandler(void)
{
  HAL_UART_IRQHandler(& UartHandle);
}


//void TIM3_IRQHandler(void)
//{
//    __HAL_TIM_CLEAR_IT(htim, TIM_IT_UPDATE);
//	doNothing();
////  if (TIM_GetITStatus(TIM3, TIM_IT_CC1) != RESET)
////  {
////    TIM_ClearITPendingBit(TIM3, TIM_IT_CC1);
////
////    /* LED1 toggling with frequency = 73.24 Hz */
////    //STM_EVAL_LEDToggle(LED1);
////	capture = TIM_GetCapture1(TIM3);
////    TIM_SetCompare1(TIM3, capture + CCR1_Val);
////  }
////  else if (TIM_GetITStatus(TIM3, TIM_IT_CC2) != RESET)
////  {
////    TIM_ClearITPendingBit(TIM3, TIM_IT_CC2);
////
////    /* LED2 toggling with frequency = 109.8 Hz */
////    //STM_EVAL_LEDToggle(LED2);
////    capture = TIM_GetCapture2(TIM3);
////    TIM_SetCompare2(TIM3, capture + CCR2_Val);
////  }
////  else if (TIM_GetITStatus(TIM3, TIM_IT_CC3) != RESET)
////  {
////    TIM_ClearITPendingBit(TIM3, TIM_IT_CC3);
////
////    /* LED3 toggling with frequency = 219.7 Hz */
////    //STM_EVAL_LEDToggle(LED3);
////    capture = TIM_GetCapture3(TIM3);
////    TIM_SetCompare3(TIM3, capture + CCR3_Val);
////  }
////  else
////  {
////    TIM_ClearITPendingBit(TIM3, TIM_IT_CC4);
////
////    /* LED4 toggling with frequency = 439.4 Hz */
////   // STM_EVAL_LEDToggle(LED4);
////    capture = TIM_GetCapture4(TIM3);
////    TIM_SetCompare4(TIM3, capture + CCR4_Val);
////  }
//}

//void TIM3_IRQn(void)
//{
//	doNothing();
//}

/******************************************************************************/
/*                 STM32F4xx Peripherals Interrupt Handlers                   */
/*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
/*  available peripheral interrupt handler's name please refer to the startup */
/*  file (startup_stm32f40xx.s/startup_stm32f427x.s).                         */
/******************************************************************************/

/**
  * @}
  */ 

/**
  * @}
  */ 

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
